#include <vector>
#include <iostream>

using namespace std;

int nonConstructibleChange(vector<int> coins) {
  sort(coins.begin(), coins.end());
  int sum = 0, i = 0;
  while (coins[i] <= sum + 1) {
    sum += coins[i];
    i++;
  }
  return sum + 1;
}

int main(int argc, char const *argv[]) {
  vector<int> coins{1, 2, 5};
  int ans = nonConstructibleChange(coins);
  cout << ans << endl;
  return 0;
}
